﻿
using System.Collections.Generic;

namespace ExtensionMethods.Test.Extensions
{
    using System;
    using Groundwork.Extensions;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using FluentAssertions;

    [TestClass]
    public class GenericTypes
    {
        [TestMethod]
        public void TestTypeHasAttribute()
        {
            testing myobject = new testing();
            myobject.HasAttribute<testAttribute>().Should().BeTrue();
        }

        [TestMethod]
        public void TestGetAttributesForType()
        {
            testing myobject = new testing();
            myobject.GetAttributes<testAttribute>().Count.Should().Be(2);
        }

        [TestMethod]
        public void TestHasPropertyTrue()
        {
            testing myobject = new testing();
            myobject.HasProperty("MyProperty").Should().BeTrue();
        }

        [TestMethod]
        public void TestHasPropertyFalse()
        {
            testing myobject = new testing();
            myobject.HasProperty("MyProperty1").Should().BeFalse();
        }

        [TestMethod]
        public void TestHasFieldTrue()
        {
            testing myobject = new testing();
            myobject.HasField("MyField").Should().BeTrue();
        }

        [TestMethod]
        public void TestHasFieldFalse()
        {
            testing myobject = new testing();
            myobject.HasField("MyField1").Should().BeFalse();
        }

        [TestMethod]
        public void TestGetAttributesForTypeNameExamineProperty()
        {
            testing myobject = new testing();
            IList<testAttribute> itemsFound = myobject.GetAttributes<testAttribute>();
            itemsFound.Count.Should().Be(2);
        }

    }

    [testAttribute("Some value")]
    [testAttribute("Some other value")]
    public class testing
    {
        public string MyProperty { get; set; }
        public bool MyField;
        
        public void MyMethod()
        {
        }
    }

    [AttributeUsage(AttributeTargets.All, AllowMultiple=true)]
    public class testAttribute : Attribute
    {
        public string Name { get; set; }
        public testAttribute(string name)
        {
            Name = name;
        }
    }

}
